import "reflect-metadata";
import { INJECTED_TOKENS } from "./constants";
export function Inject(token: string): ParameterDecorator {
  //target类本身 propertyKey方法名 parameterIndex参数的索引
  return (
    target: Object,
    propertyKey: string | symbol,
    parameterIndex: number
  ) => {
    const existingInjectTokens =
      Reflect.getMetadata(INJECTED_TOKENS, target) ?? [];
    existingInjectTokens[parameterIndex] = token;
    //把token数组保存在target的元数据上
    Reflect.defineMetadata(INJECTED_TOKENS, existingInjectTokens, target);
  };
}
 